#!/bin/bash

id=$(ps -ef | grep java | grep chat-wx | grep -v grep | awk '{print$2}')

if [ "$id" != "" ]; then
  echo "chat-wx is running, pid=$id"
else
  if [ ! -d "logs" ]; then
    echo "mkdir logs"
    mkdir logs
  fi
  if [ ! -d "tmp" ]; then
    echo "mkdir tmp"
    mkdir tmp
  fi
  nohup java -Dname=chat-wx \
  -Djava.io.tmpdir=tmp \
  -Xms500M -Xmx500M \
  -XX:ErrorFile=logs/hs_err_pid%p.log \
  -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/ \
  -XX:+PrintGCDateStamps -XX:+PrintGCDetails \
  -jar chat-wx-1.0.jar >>logs/start.log 2>&1 &
  echo "start ok"
fi
